<template>
  <el-form :model="TModel" status-icon inline>
    <slot name="form" v-if="$slots.form && !formItems"></slot>
    <el-form-item v-for="item of formItems" :key="item.label" v-bind="item">
      <T_FormItem
        v-if="!item.isSlot"
        :itemType="item.itemType"
        :type="item.type"
        :options="item.optionsList"
        v-model="TModel[item.model]"
      ></T_FormItem>
      <slot v-else :name="item.model"></slot>
    </el-form-item>
  </el-form>
</template>
<script lang="ts" setup name="T_Form">
import { FormItemType } from '@/interfaces/Element/Form'

/**
 * @return interface
 * **/
interface FormType {
  model: Object
  formItems: Array<FormItemType>
}

/**
 * @return {props,emit}
 * **/
// 默认值
const props = withDefaults(defineProps<FormType>(), {})
const emits = defineEmits(['update:model'])
const TModel = computed({
  get: () => props.model,
  set: val => {
    emits('update:model', val)
  }
})
</script>
<style lang="scss"></style>
